package com.neu.icloud.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neu.icloud.entity.Mechine;
import com.neu.icloud.service.MechineService;

@RestController
@RequestMapping("/MechineController")
public class MechineController {
	
	@Autowired
	private MechineService mechineService;

	@RequestMapping("/addMechine")
	public int addMechine(Mechine mechine) throws Exception{
		return mechineService.addMechine(mechine);
	}

	@RequestMapping("/updataMechine")
	public int updataMechine(Mechine mechine) throws Exception{
		return mechineService.updateMechine(mechine);
	}
	
	@RequestMapping("/updataMechineState")
	public int updataMechineState(Mechine mechine) throws Exception{
		return mechineService.updateMechineState(mechine);
	}

	@RequestMapping("/removeMechineByMechineId")
	public int removeMechineByMechineId(String mechineId) throws Exception{
		return mechineService.removeMechineByMechineId(mechineId);
	}

	@RequestMapping("/removeMechineByFactoryId")
	public int removeMechineByFactoryId(Integer factoryId) throws Exception{
		return mechineService.removeMechineByFactoryId(factoryId);
	}

	@RequestMapping("/listMechineByMechineId")
	public List<Mechine> listMechineByMechineId(String mechineId) throws Exception{
		return mechineService.listMechineByMechineId(mechineId);
	}

	@RequestMapping("/listMechineByFactoryId")
	public List<Mechine> listMechineByFactoryId(Integer factoryId) throws Exception{
		return mechineService.listMechineByFactoryId(factoryId);
	}
	
	@RequestMapping("/selectAll")
	public List<Mechine> selectAll() throws Exception{
		return mechineService.selectAll();
	}
	
	@RequestMapping("/runNum")
	public int runNum(String mechineState) throws Exception{
		return mechineService.runNum(mechineState);
	}
	
	@RequestMapping("/allNum")
	public int allNum() throws Exception{
		return mechineService.allNum();
	}
}
